package com.runen.infinitemovement.adapter;

import android.content.Context;
import android.content.Intent;
import android.text.TextUtils;
import android.view.View;
import android.widget.ImageView;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.viewholder.BaseViewHolder;
import com.runen.infinitemovement.R;
import com.runen.infinitemovement.activity.InviteFriendsActivity;
import com.runen.infinitemovement.activity.MyTeamActivity;
import com.runen.infinitemovement.model.entity.MemberEntity;
import com.runen.infinitemovement.tool.GlideUtils;
import com.runen.infinitemovement.widget.imageview.RoundedCornersImage;
import com.runen.rxnetlibrary.utils.LogUtil;

/**
 * Create by LiaoDuanHong
 * Create on 2021/03/01 10:34
 */
public class HomeMyTeamAdapter extends BaseQuickAdapter<MemberEntity.DataBean.TeamMemberListBean, BaseViewHolder> {
    private Context context;

    public HomeMyTeamAdapter(Context context) {
        super(R.layout.item_home_my_team);
        this.context = context;
    }

    @Override
    protected void convert(BaseViewHolder baseViewHolder, MemberEntity.DataBean.TeamMemberListBean item) {
        RoundedCornersImage rci_header = baseViewHolder.getView(R.id.rci_header);
        ImageView im_leader_flag = baseViewHolder.getView(R.id.im_leader_flag);
        ImageView iv_invite = baseViewHolder.getView(R.id.iv_invite);
        if (item.userId.equals("邀请好友")) {
            iv_invite.setVisibility(View.VISIBLE);
            rci_header.setVisibility(View.GONE);
        } else {
            iv_invite.setVisibility(View.GONE);
            rci_header.setVisibility(View.VISIBLE);
            GlideUtils.loadImage(context, item.headImgUrl, rci_header);
        }

        if (!TextUtils.isEmpty(item.nickname) && item.nickname.equals("我是队长")) {
            im_leader_flag.setVisibility(View.VISIBLE);
        } else {
            im_leader_flag.setVisibility(View.GONE);
        }

        rci_header.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                context.startActivity(new Intent(context, MyTeamActivity.class));
            }
        });

        iv_invite.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                context.startActivity(new Intent(context, InviteFriendsActivity.class));
            }
        });

    }
}
